// 导入路由
import { BrowserRouter as Router, Route, Redirect, Switch } from 'react-router-dom'
import Login from './pages/login'
import Layout from './pages/layout'
import AuthRoute from '@/components/AuthRoute'

function App() {
  return (
    <Router>
      <div className='app'>
        <Switch>
          <Route
            path='/'
            exact
            render={() => {
              // 重定向
              return <Redirect to='/home'></Redirect>
            }}
          ></Route>
          {/* 登录 */}
          <Route path='/login' component={Login}></Route>
          {/* layout  exact给了嵌套路由就出不来啦！ */}
          <AuthRoute path='/home' redPath='/login' component={Layout} />
        </Switch>
      </div>
    </Router>
  )
}

export default App
